package com.caipin.controller;

/**
 * @Author: zhunian0322@163.com
 * @DateTime: 2021-09-30 9:18
 * @Description: TODO
 */
@RestController
@RequestMapping({"/schoolSecurityHomePageManagement"})
public class AISecurityHomePageManagementController {
    @Autowired
    private AISecurityHomePageManagementService aiSecurityHomePageManagementService;

    @GetMapping({"/numberOfPeopleTakingTemperature"})
    public Object getNumberOfPeopleTakingTemperature() {
        TemperatureInfo2 temperatureInfo2 = this.aiSecurityHomePageManagementService.getNumberOfPeopleTakingTemperature();
        return ResultJson.ok(temperatureInfo2);
    }

    @GetMapping({"/historicalWarning"})
    public Object getHistoricalWarning(@RequestParam("count") int count) {
        List<HistoricalWarning> historicalWarningList = this.aiSecurityHomePageManagementService.getHistoricalWarning(count);
        return ResultJson.ok(historicalWarningList);
    }

    @GetMapping({"/eventStatistics"})
    public Object getEventStatistics(@RequestParam("unit") String unit) {
        List<EventStatistics> eventStatisticsList = null;
        if (StringUtils.isEmpty(unit))
            return ResultJson.failure(ResultCode.BAD_REQUEST);
        if (StringUtils.equals(unit, "week")) {
            eventStatisticsList = this.aiSecurityHomePageManagementService.getEventStatisticsForWeek();
        } else if (StringUtils.equals(unit, "day")) {
            eventStatisticsList = this.aiSecurityHomePageManagementService.getEventStatisticsForDay();
        }
        return ResultJson.ok(eventStatisticsList);
    }

    @GetMapping({"/strangerWarning"})
    public Object getStrangerWarning(@RequestParam("count") int count) {
        List<StrangerWarning> strangerWarningList = this.aiSecurityHomePageManagementService.getStrangerWarningList(count);
        return ResultJson.ok(strangerWarningList);
    }

    @GetMapping({"/crowdWarning"})
    public Object getCrowdWarning(@RequestParam("count") int count) {
        List<CrowdWarning> crowdWarningList = this.aiSecurityHomePageManagementService.getCrowdWarning(count);
        return ResultJson.ok(crowdWarningList);
    }

    @GetMapping({"/numberOfPeopleTakingIn"})
    Object getNumberOfPeopleTakingIn(@RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate) {
        List<InAndOutInfo> inAndOutInfoList = this.aiSecurityHomePageManagementService.getNumberOfPeopleTakingIn(startDate, endDate);
        return ResultJson.ok(inAndOutInfoList);
    }
}

